package models;

import java.util.*;

import javax.persistence.*;

import play.db.ebean.*;
import play.data.format.*;
import play.data.validation.*;


/**
 * User entity managed by Ebean
 */
@Entity
@Table(name="labs")
public class Labs extends Model {

	public static final long serialVersionUID = 1L;

	@Id
	@Column(name="idlabs")
	public long id;

    @Column(name="lab_name")
    public String labName;

    @Column(name="lab_address1")
    public String labAddress1;

    @Column(name="lab_address2")
    public String labAddress2;

    @Column(name="lab_city")
    public String labCity;

    @Column(name="lab_state")
    public String labState;

    @Column(name="lab_zip")
    public String labZip;

    @Column(name="lab_contact_no")
    public String labContactNo;
    
    @Column(name="lat")
    public Double latitude;

    @Column(name="lng")
    public Double longitude;

    @Transient
    public Double distance;


    // -- Queries

    public static Model.Finder<String,Labs> find = new Model.Finder(String.class, Labs.class);

    public static List<Labs> getAllLabs() {    
    	return find.all();
    }
    
    public static Labs getLab(long labId) {    
        return find.where()
                .eq("id", labId)
                .findUnique();
    }
    public static List<Labs> getAllLabsInCity(String city) {    
    	return find.where()
    			.eq("lab_city", city)
    			.findList();
    }

}

